import 'package:web_socket_channel/web_socket_channel.dart';

void main() {
  final channel = WebSocketChannel.connect(Uri.parse('ws://localhost:3000'));

  // 监听服务端消息
  channel.stream.listen((message) {
    print('收到服务端消息: $message');
  });

  // 向服务端发送消息
  channel.sink.add('Hello from Dart client');

  // 关闭连接
  channel.sink.close();
}
